package cn.iocoder.yudao.module.wine.dal.mysql.guaranteerecord;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.wine.dal.dataobject.guaranteerecord.GuaranteeRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.guaranteerecord.vo.*;

/**
 * 保证金记录 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface GuaranteeRecordMapper extends BaseMapperX<GuaranteeRecordDO> {

    default PageResult<GuaranteeRecordRespVO> selectPage(GuaranteeRecordPageReqVO reqVO) {
        return selectJoinPage(reqVO,GuaranteeRecordRespVO.class, new MPJLambdaWrapperX<GuaranteeRecordDO>()
                .eqIfPresent(GuaranteeRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(GuaranteeRecordDO::getGuaranteePrice, reqVO.getGuaranteePrice())
                .eqIfPresent(GuaranteeRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(GuaranteeRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GuaranteeRecordDO::getTradeNo, reqVO.getTradeNo())
                .betweenIfPresent(GuaranteeRecordDO::getTradeTime, reqVO.getTradeTime())
                .leftJoin(MemberUserDO.class,MemberUserDO::getId, GuaranteeRecordDO::getUserId)
                .selectAll(GuaranteeRecordDO.class)
                .selectAs(MemberUserDO::getName, GuaranteeRecordRespVO::getName)
                .orderByDesc(GuaranteeRecordDO::getId));
    }

}
